package com.kmxd.ams.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

/**
 * 是否存在状态
 *
 * @author nickbi
 */
@Getter
@AllArgsConstructor
public enum HaveStatusEnum {

  /** 无 */
  NO(0, "无"),
  HAVE(1, "有"),
  ;

  private Integer code;
  private String desc;

  public static HaveStatusEnum convert(Integer type) {
    return Arrays.stream(values()).filter(x -> x.code.equals(type)).findAny().orElse(NO);
  }

  @JsonCreator
  public static HaveStatusEnum getValue(Integer type) {
    return Arrays.stream(values()).filter(x -> Objects.equals(x.code, type)).findAny().orElse(null);
  }
}
